package net.crowdloud.client.groups;

import net.crowdloud.client.GlobalVariables;
import net.crowdloud.client.Home;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;

public class GetGroups {

	public GetGroups() {

		final GroupsDatabaseServerCallsAsync databaseServerCalls = GWT
				.create(GroupsDatabaseServerCalls.class);

		databaseServerCalls.getGroups(new AsyncCallback<String>() {

			public void onSuccess(String groups) {

				GlobalVariables.groups = groups;

				String[] groupsArray = groups.split(",");

				RootPanel.get("groupList").clear();
				// RootPanel.get("livefeedmid").add(new
				// GroupsList(groupsArray));
				RootPanel.get("groupList").add(new Home(groupsArray));
			}

			public void onFailure(Throwable caught) {
				// Show the RPC error message to the user

			}

		});

	}

}
